package com.util;

import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;

import java.sql.SQLOutput;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class myutil {
    public Map<String,String>readXML()throws Exception {
        Map<String, String> map = new HashMap<String, String>();
        SAXBuilder saxBuilder = new SAXBuilder();
        String path = myutil.class.getResource("/").getPath() + "db-config,xml";
        Document doc = saxBuilder.build(path);
        Element e = doc.getRootElement();
        List list = e.getChildren();
        for (int i = 0; i < list.size(); i++) {
            System.out.println(e.getName());
        }
        return map;
    }
    }
    class MyUtil {

        public static Map<String, String> readXNL() throws Exception {
            Map<String, String> map = new HashMap<String, String>();
            SAXBuilder saxBuilder = new SAXBuilder();
            String Path = myutil.class.getResource("/").getPath() + "db-config.xml";
            Document doc = saxBuilder.build(Path);
            Element rootelment = doc.getRootElement();
            System.out.println(rootelment.getName());
            List<Element> listall = rootelment.getChildren();
            for (int i = 0; i < listall.size(); i++) {
                System.out.println("" + i + ":" + listall.get(i).getName());
            }
            Iterator iter = listall.iterator();
            while (iter.hasNext()) {
                Element e = (Element) iter.next();
                System.out.println(e.getName() + "" + e.getText());
map.put(e.getName(),e.getText());
            }
            return map;
        }
    }

